package com.example.my.meila.view.fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.my.meila.R;
import com.example.my.meila.view.adapter.beautyadapter.BeautyPageAdapter;
import com.example.my.meila.view.fragment.beautychildfrg.GoodFragment;
import com.example.my.meila.view.fragment.beautychildfrg.MakeUpFragment;
import com.example.my.meila.view.fragment.beautychildfrg.NotifyFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * A simple {@link Fragment} subclass.
 */
public class BeautyFragment extends Fragment {
    @BindView(R.id.beauty_tab)
    TabLayout beautyTab;
    @BindView(R.id.beauty_vp)
    ViewPager beautyVp;
    private List<Fragment> data = new ArrayList<>();


    public BeautyFragment() {

    }

    public static BeautyFragment newInstance() {

        Bundle args = new Bundle();

        BeautyFragment fragment = new BeautyFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_beauty, container, false);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        data.add(new GoodFragment().newInstance());
        data.add(new MakeUpFragment().newInstance());
        data.add(new NotifyFragment().newInstance());
        this.beautyVp.setAdapter(new BeautyPageAdapter(getChildFragmentManager(),data));
        this.beautyTab.setupWithViewPager(beautyVp);
    }

}
